var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database('/Users/jiangleivos/alibaba-work/DB/db');
var arr = ['01','02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20']

var s1 = '.separator ,;';
var s2 = '.headers on;';
var s3 = '.output keyword_?.csv;';
var s4 = 'select keyword,min_avgCpc,min_avgPos,min_clickPerDay,min_totalCost,max_avgCpc,max_avgPos,max_clickPerDay,max_totalCost from keyword_rst_?;'
db.serialize(function() {
    // console.log(s);
    function callback(){
        console.log(arguments)
    }
    arr.forEach(function(item) {
        // console.log(t.replace('?',item.toString()));
        db.exec(s1,callback);
        db.exec(s2,callback);
        db.exec(s3.replace('?',item.toString()),callback);
        db.exec(s4.replace('?',item.toString()),callback);
    })
})
// db.end();